import 'package:fsharing/core/models/order_confirm.dart' as orderConfirm;
import 'package:json_annotation/json_annotation.dart';

part 'address.g.dart';

@JsonSerializable()
class Address {
  final int id;
  final String linkMan;
  final String contactPhone;
  final String verifyCode;
  final int countyId;
  final String provCityCounty;
  final String detailAddress;
  final bool defaulted;
  final String encryptedCode;

  Address(
    this.id,
    this.linkMan,
    this.contactPhone,
    this.verifyCode,
    this.countyId,
    this.provCityCounty,
    this.detailAddress,
    this.defaulted,
    this.encryptedCode,
  );

  factory Address.fromJson(Map<String, dynamic> json) => _$AddressFromJson(json);

  Map<String, dynamic> toJson() => _$AddressToJson(this);

  orderConfirm.Address toAddress() {
    return orderConfirm.Address(
      id,
      linkMan,
      contactPhone,
      provCityCounty + detailAddress,
    );
  }
}
